package com.tjetc._2string;

public class _4StringBufferMethod {
    public static void main(String[] args) {
        StringBuilder stringBuffer = new StringBuilder("abc");
//        stringBuffer stringBuffer = new StringBuffer("abc");

        // 增加
        stringBuffer.append(1);
        System.out.println(stringBuffer);
        // 链式调用
        stringBuffer.append(1).append(2);

        // 删除
        StringBuffer stringBuffer1 = new StringBuffer("123");
        stringBuffer1.delete(0, 6);
        System.out.println(stringBuffer1);

        // 替换
        StringBuffer stringBuffer2 = new StringBuffer("1234");
        stringBuffer2.replace(1, 3, "a");
        System.out.println(stringBuffer2);

        // 插入
        StringBuffer stringBuffer3 = new StringBuffer("1234");
        stringBuffer3.insert(2, "a");
        System.out.println(stringBuffer3);
    }
}
